package ai.astar;

import java.awt.Color;
import java.awt.Graphics;
import java.util.Vector;

import ai.application.Config;
import ai.gui.Drawable;

public class Node implements Drawable {

	private String id;
	private double x,y;
	private Node predecessorNode;
    private Vector<Link> neighbors;
    private double distance;
    private double rankingDistance;
  
    public double getRankingDistance() {
		return rankingDistance;
	}

	public void setRankingDistance(double euclidDistance) {
		this.rankingDistance = euclidDistance;
	}

	public Node(String id, double x, double y){
    	neighbors = new Vector<Link>();
    	this.id = id;
    	this.x = x;
    	this.y = y;
    }

	public String getId() {
		return id;
	}
	
    public double getX() {
		return x;
	}

	public void setX(double x) {
		this.x = x;
    	if(this.x > 740){
    		System.out.println(this.id);
    	}
	}
	
	public double getY() {
		return y;
	}

	public void setY(double y) {
		this.y = y;
	}

	public Node getPredecessorNode() {
		return predecessorNode;
	}


	public void setPredecessorNode(Node predecessorNode) {
		this.predecessorNode = predecessorNode;
	}


	public Vector<Link> getNeighbors() {
		return neighbors;
	}


	public void setNeighbors(Vector<Link> neighbors) {
		this.neighbors = neighbors;
	}


	public double getDistance() {
		return distance;
	}


	public void setDistance(double dist) {
		this.distance = dist;
	}

	@Override
	public void draw(Graphics g) {
		int diameter = 5;
		if(this.id.equals(Config.START_NODE) || this.id.equals(Config.TARGET_NODE)){
			diameter = 12;
			g.setColor(Color.RED);
		}else{
			g.setColor(Color.GRAY);
		}
		g.fillOval((int)x-diameter/2, (int)y-diameter/2, diameter, diameter);
		g.setColor(Color.BLACK);
		for (Link neighbor : this.neighbors) {
			g.drawLine((int)this.x, (int)this.y, (int)neighbor.getTo().getX(), (int)neighbor.getTo().getY());
		}
		
	}
}
